//package org.chs.ts.batch.job;
//
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
//import com.sun.deploy.util.ParameterUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.chs.ts.base.batch.exec.entity.BatchDailyBasicTaskStepExec;
//import org.chs.ts.base.batch.log.entity.BatchClearBasicLog;
//import org.chs.ts.base.batch.set.entity.BatchDailyBasicTaskPublish;
//import org.chs.ts.base.batch.vo.entity.BatchDailyConfirmReq;
//import org.chs.ts.base.batch.vo.entity.BatchDailyExecResp;
//import org.chs.ts.base.batch.vo.entity.BatchDailyGetTaskResp;
//import org.chs.ts.base.common.util.oConvertUtils;
//import org.chs.ts.base.constant.CommonConstant;
//import org.chs.ts.base.vo.Result;
//import org.chs.ts.batch.controller.BatchDailyExecController;
//
//import org.chs.ts.batch.service.IBatchClearBasicLogService;
//import org.chs.ts.batch.service.IBatchDailyBasicTaskPublishService;
//import org.chs.ts.batch.service.IBatchDailyBasicTaskStepExecService;
//import org.chs.ts.batch.util.CommonUtil;
//import org.chs.ts.batch.util.ConvertToUtil;
//import org.springframework.core.env.Environment;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.text.SimpleDateFormat;
//import java.util.Arrays;
//import java.util.Date;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * @Compay 盛唐天行
// * @Author: wuwei
// * @Censor By wuwei
// * @Sence 2023/5/29 11:15
// * @Modify 2023/5/29 11:15
// * @Description 定时跑批job 日间跑批任务
// */
//@EnableScheduling
//@Component
//@Slf4j
//public class BatchDailyTaskScheduled {
//    //@Resource
//    //private RedissonLockService redissonLockService;
//    @Resource
//    private BatchDailyExecController dailyExecController;
//    @Resource
//    private ParameterUtil parameterUtil;
//    @Resource
//    private Environment environment;
//
//    @Resource
//    private IBatchClearBasicLogService clearBasicLogService;
//
//    @Resource
//    private IBatchDailyBasicTaskPublishService dailyTaskPublishService;
//
//    @Resource
//    private IBatchDailyBasicTaskStepExecService dailyTaskStepExecService;
//
//    private final String batchSysCode = "MWBP";
//
//    private int MAX_ERROR_COUNT = 5;
//    private final long MAX_WAITTING_TIME = 5000;
//
//    private final boolean isDebug = false;
//
//    // 每小时 00分05秒 30分05秒 执行
//    //@Scheduled(cron = "5 * * * * ?")
//    public void process() {
//        String key = "BatchDailyTaskScheduled";
//
//        //try {
//            //redissonLockService.dealLockAndUnlock(key, () -> {
//            //    log.info(key + " 执行日志 BatchDailyTaskScheduled" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//            //    String mwbpTransDay = parameterUtil.getParameterByCode(ParamConstant.MWBP_TRANS_DAY);
//            //
//            //    dailyInit(mwbpTransDay);
//            //    // EndOfDayExecute();
//            //    dailyExecute(mwbpTransDay);
//            //
//            //    log.info(key + " 执行结束 BatchDailyTaskScheduled" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//        //    }, new ServiceException(RetCode.FAILED, "未能获取锁，等待下次重新获取"));
//        //} catch (ServiceException e) {
//        //    log.info(e.getMessage());
//        //}
//
//    }
//
//    /**
//     * 初始化 日间跑批任务
//     */
//    private void dailyInit(String mwbpTransDay) {
//
//        log.info("BatchDailyTaskScheduled -> dailyInit mwbpTransDay:" + mwbpTransDay + " start!");
//        // 每日执行一次
//        // 获取执行日志
//        String upgradeDailyTaskPublishLogSernoPrdfix = "UpgradeDailyTaskPublish".toUpperCase() + mwbpTransDay;
//        boolean basicLogIsEmpty = clearBasicLogService.list(new LambdaQueryWrapper<BatchClearBasicLog>().likeRight(BatchClearBasicLog::getLogSerno,
//                upgradeDailyTaskPublishLogSernoPrdfix)).isEmpty();
//        if (isDebug || basicLogIsEmpty) {
//            upgradeDailyTaskPublishStauts(mwbpTransDay, upgradeDailyTaskPublishLogSernoPrdfix);
//            createDailyTaskStepExec(mwbpTransDay);
//        }
//
//        //
//        log.info("BatchDailyTaskScheduled -> dailyInit mwbpTransDay:" + mwbpTransDay + " end!");
//
//    }
//
//    private void createDailyTaskStepExec(String mwbpTransDay) {
//        // 获取 日间跑批任务列表
//        List<BatchDailyBasicTaskPublish> dailytaskPubList = dailyTaskPublishService.list(new LambdaQueryWrapper<BatchDailyBasicTaskPublish>()
//                .in(BatchDailyBasicTaskPublish::getTaskPubStauts, Arrays.asList("0", "1"))
//                .ge(BatchDailyBasicTaskPublish::getEndDate, mwbpTransDay)
//        );
//
//        for (BatchDailyBasicTaskPublish item : dailytaskPubList) {
//            BatchDailyConfirmReq req = new BatchDailyConfirmReq();
//            req.setTaskPubId(item.getTaskPubId());
//            req.setBatchSysCode(item.getBatchSysCode());
//
//            Result<String> stringResult = dailyExecController.confirmDailyTask(req);
//            log.info("BatchDailyTaskScheduled -> dailyInit -> createDailyTaskStepExec -> confirmDailyTask " +
//                    "result:" + stringResult.getResult() + stringResult.getMessage() + " request:" + req.getTaskPubId() + "@" + req.getBatchSysCode());
//        }
//
//    }
//
//    private void upgradeDailyTaskPublishStauts(String mwbpTransDay, String logSernoPrdfix) {
//        log.info("BatchDailyTaskScheduled -> dailyInit -> upgradeDailyTaskPublishStauts mwbpTransDay:" + mwbpTransDay + " start!");
//
//        String currentTime = new SimpleDateFormat("HHmmss").format(new Date());
//
//        // 更新日间跑批计划
//        List<BatchDailyBasicTaskPublish> dailyTasklist = dailyTaskPublishService.list(new LambdaQueryWrapper<BatchDailyBasicTaskPublish>()
//                .in(BatchDailyBasicTaskPublish::getTaskPubStauts, Arrays.asList("0", "1"))
//                .lt(BatchDailyBasicTaskPublish::getEndDate, mwbpTransDay)
//        );
//
//        if (dailyTasklist.isEmpty()) {
//            return;
//        }
//        // 处理到期 日间跑批计划
//        for (BatchDailyBasicTaskPublish item : dailyTasklist) {
//            dailyTaskStepExecService.update(new BatchDailyBasicTaskStepExec().setExecStatus("6"),
//                    new LambdaUpdateWrapper<BatchDailyBasicTaskStepExec>()
//                            .eq(BatchDailyBasicTaskStepExec::getTaskPubId, item.getTaskPubId())
//                            .in(BatchDailyBasicTaskStepExec::getExecStatus, Arrays.asList("0", "4", "5")));
//
//        }
//
//
//        if (dailyTaskPublishService.update(new BatchDailyBasicTaskPublish().setTaskPubStauts("9"),
//                new LambdaUpdateWrapper<BatchDailyBasicTaskPublish>().in(BatchDailyBasicTaskPublish::getTaskPubId,
//                        dailyTasklist.stream().map(BatchDailyBasicTaskPublish::getTaskPubId).collect(Collectors.toList())))) {
//            insertBasicClearBasicLog(logSernoPrdfix + currentTime, mwbpTransDay, "3", true, "BatchDailyTaskScheduled -> " +
//                    "upgradeDailyTaskPublishStauts mwbpTransDay:" + mwbpTransDay);
//        }
//        log.info("BatchDailyTaskScheduled -> dailyInit -> upgradeDailyTaskPublishStauts mwbpTransDay:" + mwbpTransDay + " end!");
//
//
//    }
//
//    private void insertBasicClearBasicLog(String logSerno, String mwbpTransDay, String execStatus, boolean runningResult, String rtnDesc) {
//        BatchClearBasicLog clearBasicLog = new BatchClearBasicLog();
//        String ip = CommonUtil.getLocalHostAddress();
//        String port = environment.getProperty("server.port");
//        String path = oConvertUtils.getString(environment.getProperty("server.servlet.context-path"));
//
//        clearBasicLog.setLogSerno(logSerno);
//        clearBasicLog.setTaskExecid("");
//        clearBasicLog.setTaskGroup("");
//        clearBasicLog.setTaskId("");
//        clearBasicLog.setStepNo("");
//        clearBasicLog.setTaskDate(mwbpTransDay);
//        clearBasicLog.setExecStatus(execStatus);
//        clearBasicLog.setExecDate(mwbpTransDay);
//        clearBasicLog.setShouldExecDate(mwbpTransDay);
//        clearBasicLog.setTargetCode("");
//        clearBasicLog.setProdCode("");
//        clearBasicLog.setStartTime("");
//        clearBasicLog.setEndTime("");
//        clearBasicLog.setThreadUuid("");
//        clearBasicLog.setServerName(path);// 服务器主机名
//        clearBasicLog.setServerIp(ip + ":" + port);// 服务器IP
//        clearBasicLog.setRtnCode(runningResult ? CommonConstant.RTN_CODE_SUCCESS : CommonConstant.RTN_CODE_FAILED);// 返回码
//        clearBasicLog.setRtnDesc(rtnDesc);
//
//        clearBasicLogService.save(clearBasicLog);
//    }
//
//    /**
//     * 日间跑批执行方法
//     */
//    private void dailyExecute(String mwbpTransDay) {
//        int maxNum = 5;
//        Result<BatchDailyGetTaskResp> getTaskRespResult;
//        do {
//            getTaskRespResult = dailyExecController.getTask(batchSysCode, mwbpTransDay, maxNum);
//            // 获取日间跑批抢夺操作失败: 999999   执行日间跑批任务完成: 111111  执行日间跑批任务调用成功: 000000
//
//            if (getTaskRespResult.getCode().compareTo(Integer.valueOf("999999")) == 0) {
//                try {
//                    log.info("BatchDailyTaskScheduled -> dailyExecute -> getTask error try again!");
//                    Thread.sleep(MAX_ERROR_COUNT*MAX_WAITTING_TIME);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
//                MAX_ERROR_COUNT--;
//            }else{
//                break;
//            }
//        } while (MAX_ERROR_COUNT > 0);
//
//        List<BatchDailyBasicTaskStepExec> taskDailyStepExecList = getTaskRespResult.getResult().getTaskDailyStepExecList();
//        if (!taskDailyStepExecList.isEmpty()) {
//            for (BatchDailyBasicTaskStepExec item : taskDailyStepExecList) {
//                BatchDailyExecResp processResp = dailyExecController.process(item.getTaskPubId());
//                if (processResp.getRtnCode().equals(CommonConstant.RTN_CODE_SUCCESS)) {
//                    log.info("BatchDailyTaskScheduled -> dailyExecute -> process taskPubId:" + item.getTaskPubId() + " error!");
//                    log.info("BatchDailyTaskScheduled -> dailyExecute -> getTask List:"+printObjectInfoBatchDailyBasicTaskStepExec(taskDailyStepExecList)+"!");
//                    break;
//                }
//            }
//        }
//
//    }
//
//    private String printObjectInfoBatchDailyBasicTaskStepExec(List<BatchDailyBasicTaskStepExec> objList) {
//
//        StringBuilder result;
//        result = new StringBuilder();
//        for (BatchDailyBasicTaskStepExec obj : objList) {
//            result.append(printObjectInfo(obj, Arrays.asList("batchSysCode","stepNo","stepName","taskExecid","stepParamsVersion","stepParams")));
//        }
//        return result.toString();
//    }
//
//    private String printObjectInfo(BatchDailyBasicTaskStepExec obj, List<String> fieldList) {
//        return ConvertToUtil.printObjectInfo(obj, fieldList);
//
//    }
//
//    /**
//     * 日终跑批执行方法
//     */
////    private void EndOfDayExecute() {
////
////        boolean isGetWaitting = false;
////        // 获取 待执行 列表
////        initParameter();
////        for (BatchClearBasicGroupInfoSet taskGroup : this.taskGroupList) {
////            // 获取参数
////            String runningTime = getGroupInfoParameter(taskGroup.getTaskGroup(), taskGroup.getPreTaskParameter(), "runningTime");
////            String diffDate = getGroupInfoParameter(taskGroup.getTaskGroup(), taskGroup.getPreTaskParameter(), "diffDate");
////            boolean isRestrictExecTime = getGroupInfoTypeOfBoolean(taskGroup.getTaskGroup(), taskGroup.getPreTaskParameter(),
////                    "isRestrictExecTime");
////            // 增加执行时间限制
////            if (isRestrictExecTime) {
////                if (!(checkCurrentTime(runningTime))) {
////                    log.info("EndOfDayExecute 执行日志-跑批组未在可执行时间 taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate -> [" + this.execDate +
////                            "]" + " runningTime -> [" + runningTime + "]" + "diffDate -> [" + diffDate + "]isRestrictExecTime -> [" +
////                            isRestrictExecTime + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                    //createClearBasicLog(false, "BatchTaskScheduled 执行日志-跑批组未在可执行时间 taskGroup -> [" + this.taskGroup + "] execDate -> [" +
////                    // this.execDate + "] snatchingMode -> [" + this.snatchingMode + "]" + " runningTime -> [" + runningTime + "]" + "
////                    // isRestrictExecTime -> [" + isRestrictExecTime + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
////                    // , "");
////                    continue;
////                }
////            }
////
////            //createClearBasicLog(true, "BatchTaskScheduled 执行日志-跑批组在可执行时间,准备获取可执行列表 taskGroup -> [" + this.taskGroup + "] execDate -> [" +
////            // this.execDate + "] snatchingMode -> [" + this.snatchingMode + "]" + " runningTime -> [" + runningTime + "]" + "
////            // isRestrictExecTime -> [" + isRestrictExecTime + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), "");
////            log.info("EndOfDayExecute 执行日志-跑批组在可执行时间，准备获取可执行列表 taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate -> [" + this.execDate +
////                    "]" + " runningTime -> [" + runningTime + "]" + "diffDate -> [" + diffDate + "]isRestrictExecTime -> [" + isRestrictExecTime +
////                    "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////
////            // 根据 获取 有效 taskgroupID
////            BatchExecReq taskWaittingList = batchExecController.getTaskWaittingList(taskGroup.getBatchSysCode(), taskGroup.getTaskGroup(),
////                    this.execDate);
////            if (taskWaittingList == null || taskWaittingList.getTaskGroup() == null) {
////                // 未获取待执行跑批计划列表
////                log.info("EndOfDayExecute 执行日志-跑批组在可执行时间，未获取可执行列表 taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate -> [" + this.execDate +
////                        "]" + " runningTime -> [" + runningTime + "]" + "diffDate -> [" + diffDate + "]isRestrictExecTime -> [" +
////                        isRestrictExecTime + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                continue;
////            }
////            this.batchSysCode = taskWaittingList.getBatchSysCode();
////            this.taskGroup = taskWaittingList.getTaskGroup();
////            this.snatchingMode = taskWaittingList.getSnatchingMode();
////            // 确认当前跑批列表
////            isGetWaitting = batchExecController.confirmTaskWaitting(this.batchSysCode, this.taskGroup, this.execDate, this.snatchingMode);
////            if (isGetWaitting) {
////                log.info("EndOfDayExecute 执行日志-跑批组在可执行时间，确认跑批列表成功！ taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate -> [" + this.execDate
////                + "]" + " runningTime -> [" + runningTime + "]" + "diffDate -> [" + diffDate + "]isRestrictExecTime -> [" + isRestrictExecTime +
////                "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                createClearBasicLog(true,
////                        "EndOfDayExecute 执行日志-跑批组在可执行时间，确认跑批列表成功 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate +
////                                "] snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),
////                        "");
////                break;
////            } else {
////                log.info("EndOfDayExecute 执行日志-跑批组在可执行时间，跑批组在可执行时间，确认跑批列表失败！ taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate ->" +
////                        " [" + this.execDate + "]" + " runningTime -> [" + runningTime + "]" + "diffDate -> [" + diffDate +
////                        "]isRestrictExecTime -> [" + isRestrictExecTime + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                createClearBasicLog(false,
////                        "EndOfDayExecute 执行日志-跑批组在可执行时间，跑批组在可执行时间，确认跑批列表失败！ taskGroup -> [" + taskGroup.getTaskGroup() + "] execDate -> " +
////                                "[" + this.execDate + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), "");
////            }
////
////
////        }
////        if (isGetWaitting) {
////            // 获取 当前待执行 taskGroup 信息 准备后续 进行执行
////            log.info("EndOfDayExecute 执行日志-获取可执行文件组 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate + "] " +
////                    "snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////            createClearBasicLog(true,
////                    "EndOfDayExecute 执行日志-获取可执行文件组 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate + "] " +
////                            "snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), "");
////            boolean runningStatus = startTaskRunningStatus(this.batchSysCode, this.taskGroup, this.execDate);
////            if (!runningStatus) {
////                createClearBasicLog(false,
////                        "EndOfDayExecute 执行日志-开启跑批状态失败 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate + "] " +
////                                "snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()),
////                                "");
////                return;
////            }
////            int i = 0;
////            while (i < MAX_ERROR_COUNT) {
////                //log.info("BatchTaskScheduled 执行日志:跑批定时任务!获取跑批任务 taskGroup[" + this.taskGroup + "] execDate[" + this.execDate + "]
////                // snatchingMode[" + this.snatchingMode + "] " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                Result<BatchExecResp> task = batchExecController.getTask(this.batchSysCode, this.taskGroup, this.execDate,
////                        this.snatchingMode);
////                if (task.getResult().getRtnCode().equals("000000")) {
////                    // 获取 待执行记录 进行执行
////                    //log.info("BatchTaskScheduled 执行日志:跑批定时任务!执行跑批任务 taskGroup[" + this.taskGroup + "] execDate[" + this.execDate + "]
////                    // snatchingMode[" + this.snatchingMode + "] taskExecId[" + task.getResult().getTaskExecId() + "]" + new
////                    // SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                    try {
////                        batchExecController.process(task.getResult().getTaskExecId(), this.snatchingMode);
////                        createClearBasicLog(false,
////                                "EndOfDayExecute 执行日志:跑批定时任务!任务编号" + task.getResult().getTaskExecId() + "运行" + new SimpleDateFormat(
////                                        "yyyy-MM-dd HH:mm:ss").format(new Date()), execDate);
////                    } catch (Exception e) {
////                        // e.printStackTrace();
////                        createClearBasicLog(false,
////                                "EndOfDayExecute 执行日志:跑批定时任务!任务编号" + task.getResult().getTaskExecId() + "异常" + e.getMessage() + new
////                                SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()), execDate);
////                    }
////                    try {
////                        Thread.sleep(MAX_WAITTING_TIME);
////                    } catch (InterruptedException e) {
////                        //e.printStackTrace();
////                    }
////                    // 计数器清零
////                    i = 0;
////                }
////
////                if (task.getResult().getRtnCode().equals("999999")) {
////                    //log.info("BatchTaskScheduled 执行日志:跑批定时任务!第" + (i + 1) + "次抢夺跑批任务失败 taskGroup[" + this.taskGroup + "] execDate[" +
////                    // this.execDate + "] snatchingMode[" + this.snatchingMode + "] taskExecId[" + task.getResult().getTaskExecId() + "]" +
////                    // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                    // 未获取 待执行任务 进行幂等 稍后调用
////                    try {
////                        Thread.sleep((long) Math.pow(2, (double) i++ / 5) * MAX_WAITTING_TIME);
////                    } catch (InterruptedException e) {
////                        //e.printStackTrace();
////                    }
////                    continue;
////                }
////
////                if (task.getResult().getRtnCode().equals("111111")) {
////                    //log.info("BatchTaskScheduled 执行日志:跑批定时任务!执行跑批任务完成 taskGroup[" + taskGroup + "] execDate[" + execDate + "]
////                    // snatchingMode[" + snatchingMode + "] taskExecId[" + task.getResult().getTaskExecId() + "]" + new SimpleDateFormat
////                    // ("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                    // 关闭 跑批任务
////                    boolean stopRunningStatus = stopTaskRunningStatus(this.batchSysCode, this.taskGroup, this.execDate);
////                    if (!stopRunningStatus) {
////                        createClearBasicLog(false,
////                                "EndOfDayExecute 执行日志-关闭跑批状态失败 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate + "]" +
////                                        " snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new
////                                        Date()), "");
////                    }
////
////                    // 执行列表结束 跳出循环
////                    break;
////                }
////            }
////
////            // 针对达到 运行最大次数 而未完成的内容 关闭运行状态
////            stopTaskRunningStatus(this.batchSysCode, this.taskGroup, this.execDate);
////
////        }
////    }
////
////    private boolean stopTaskRunningStatus(String batchSysCode, String taskGroup, String execDate) {
////        Boolean taskRunningStatus = batchExecController.getTaskRunningStatus(batchSysCode, taskGroup, execDate, this.snatchingMode);
////        boolean resultStatus = false;
////        if (taskRunningStatus) {
////            for (int i = 0; i < MAX_ERROR_COUNT; i++) {
////                log.info("EndOfDayExecute 执行日志-第[" + (i + 1) + "]次开启跑批状态 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate +
////                        "] snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                resultStatus = batchExecController.stopTaskRunningStatus(batchSysCode, taskGroup, execDate, this.snatchingMode);
////                // 开启成功 终止当前循环
////                if (resultStatus) {
////                    break;
////                }
////                // 开启失败 暂停5000毫秒
////                try {
////                    Thread.sleep(MAX_WAITTING_TIME);
////                } catch (InterruptedException e) {
////                    throw new RuntimeException(e);
////                }
////            }
////        } else {
////            // 当前 运行状态 为未运行 无需进行关闭操作 故返回结果为true
////            resultStatus = true;
////        }
////        return resultStatus;
////
////    }
////
////    /**
////     * 开启 跑批状态 如开启失败 将进行多次开启
////     *
////     * @param taskGroup 跑批过程组
////     * @param execDate  跑批执行时间
////     * @return 开启指定跑批执行时间 跑批过程组 状态
////     */
////    private boolean startTaskRunningStatus(String batchSysCode, String taskGroup, String execDate) {
////        Boolean taskRunningStatus = batchExecController.getTaskRunningStatus(batchSysCode, taskGroup, execDate, this.snatchingMode);
////        if (!taskRunningStatus) {
////            for (int i = 0; i < MAX_ERROR_COUNT; i++) {
////                log.info("EndOfDayExecute 执行日志-第[" + (i + 1) + "]次开启跑批状态 taskGroup -> [" + this.taskGroup + "] execDate -> [" + this.execDate +
////                        "] snatchingMode -> [" + this.snatchingMode + "]" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                taskRunningStatus = batchExecController.startTaskRunningStatus(batchSysCode, taskGroup, execDate, this.snatchingMode);
////                // 开启成功 终止当前循环
////                if (taskRunningStatus) {
////                    break;
////                }
////                // 开启失败 暂停5000毫秒
////                try {
////                    Thread.sleep(MAX_WAITTING_TIME);
////                } catch (InterruptedException e) {
////                    throw new RuntimeException(e);
////                }
////            }
////        }
////        return taskRunningStatus;
////    }
////
////    /**
////     * 验证当前时间 是否可执行跑批操作
////     *
////     * @param cut_time 系统参数 日切时间
////     * @return boolean
////     * @Description 先解析小时，确认小时是否符合
////     */
////    private Boolean checkCurrentTime(String cut_time) {
////        Date current_datatime = new Date();
////        String sys_current_time = new SimpleDateFormat("HH:mm:ss").format(current_datatime);
////        String[] sys_current_time_split = sys_current_time.split(":");
////        String[] cut_time_split = cut_time.split(":");
////
////        String sys_current_hour = sys_current_time_split[0];
////        String cut_hour = cut_time_split[0];
////        // 当前 时 不一致
////        if (!sys_current_hour.equals(cut_hour)) {
////            return false;
////        }
////
////        // 判断当前时间
////        BigDecimal cut_time_decimal = new BigDecimal(cut_time_split[1] + cut_time_split[2]);
////        BigDecimal sys_current_time_decimal = new BigDecimal(sys_current_time_split[1] + sys_current_time_split[2]);
////        // 当前时间 大于 指定 日切时间
////        return sys_current_time_decimal.compareTo(cut_time_decimal) >= 0;
////    }
////
////
////    /**
////     * 初始化参数
////     */
////    private void initParameter() {
////        this.execDate = parameterUtil.getParameterByCode(ParamConstant.LAST_DAY);
////        //this.coreDay = parameterUtil.getParameterByCode(ParamConstant.CORE_DAY);
////        this.taskGroup = "";
////        this.snatchingMode = "";
////        this.taskGroupList = clearBasicGroupInfoService.getAvailabilityGroupInfo();
////
////    }
////
////    private boolean getGroupInfoTypeOfBoolean(String taskGroup, String preTaskParameter, String key) {
////        boolean result = false;
////        String result_str = getGroupInfoParameter(taskGroup, preTaskParameter, key);
////
////        if (!Strings.isBlank(result_str)) {
////            result = Boolean.parseBoolean(result_str);
////        }
////
////        return result;
////    }
////
////    private String getGroupInfoParameter(String taskGroup, String preTaskParameter, String key) {
////        String logSernoPrdfix = "groupInfoParameter";
////        String returnValue = "";
////        if (Strings.isBlank(preTaskParameter) || preTaskParameter.equals("{}")) {
////            createClearBasicLog(false, "获取跑批组参数为空! taskGroup -> " + taskGroup + " preTaskParameter -> " + preTaskParameter, "", logSernoPrdfix);
////            log.info("getGroupInfoParameter:获取跑批组参数异常  获取跑批组参数为空! taskGroup -> " + taskGroup + " preTaskParameter -> " + preTaskParameter + new
////            SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////        } else {
////            try {
////                JSONObject parameter = JSONObject.parseObject(preTaskParameter);
////                if (parameter.containsValue(key)) {
////                    createClearBasicLog(false,
////                            "获取跑批组参数key不存在! taskGroup -> " + taskGroup + " preTaskParameter -> " + preTaskParameter + " key -> " + key, "",
////                            logSernoPrdfix);
////                    log.info("getGroupInfoParameter:获取跑批组参数异常  获取跑批组参数key不存在! taskGroup -> " + taskGroup + " preTaskParameter -> " +
////                    preTaskParameter + " key -> " + key + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////                }
////                returnValue = parameter.getString(key);
////            } catch (JSONException e) {
////                createClearBasicLog(false,
////                        "获取跑批组参数异常! taskGroup -> " + taskGroup + " preTaskParameter -> " + preTaskParameter + " " + e.getMessage(), "",
////                        logSernoPrdfix);
////                log.info("getGroupInfoParameter:获取跑批组参数异常  获取跑批组参数异常! taskGroup -> " + taskGroup + " preTaskParameter -> " + preTaskParameter + "
////                " + e.getMessage() + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
////            }
////        }
////        return returnValue;
////    }
////
////    private void createClearBasicLog(boolean runningResult, String errMsg, String currentDate, String logSernoPrdfix) {
////        if (logSernoPrdfix.length() > 19) {
////            logSernoPrdfix = logSernoPrdfix.substring(0, 19);
////            log.error("createClearBasicLog -> logSernoPrdfix参数过长请及时调整，参数长度应小于等于1位： " + logSernoPrdfix + "[" + logSernoPrdfix.length() + "]");
////        }
////        currentDate = currentDate.equals("") ? new SimpleDateFormat("yyyyMMdd").format(new Date()) : currentDate;
////        String ip = CommonUtil.getLocalHostAddress();
////        String port = environment.getProperty("server.port");
////        String path = oConvertUtils.getString(environment.getProperty("server.servlet.context-path"));
////
////        BatchClearBasicLog clearBasicLog = new BatchClearBasicLog();
////        clearBasicLog.setSysOrgCode("");//所属部门
////        clearBasicLog.setLogSerno(logSernoPrdfix.toUpperCase(Locale.ROOT) + System.currentTimeMillis());//日志号
////        clearBasicLog.setTaskDate(currentDate);//清算业务日期
////        clearBasicLog.setExecStatus(runningResult ? "3" : "4");//执行状态 (0-未执行; 1-占用中; 2-执行中;   3-执行成功; 4-执行失败; 5-跳过执行; 6-任务终止; )
////        clearBasicLog.setExecDate(currentDate);//执行日期
////        clearBasicLog.setShouldExecDate(currentDate);//应执行日期
////        clearBasicLog.setServerName(path);//服务器主机名
////        clearBasicLog.setServerIp(ip + ":" + port);//服务器IP
////        clearBasicLog.setRtnCode(runningResult ? RetCode.SUCCESS : RetCode.FAILED);//返回码
////        clearBasicLog.setRtnDesc(errMsg);//执行结束信息
////
////        clearBasicLogService.save(clearBasicLog);
////
////    }
////
////    private void createClearBasicLog(boolean runningResult, String errMsg, String currentDate) {
////        String logSernoPrdfix = "BatchTaskScheduled";
////        createClearBasicLog(runningResult, errMsg, currentDate, logSernoPrdfix);
////    }
//}
